﻿<%@ Control Language="C#" Inherits="Yuanlin.Business.CompanyCardAddControl, Yuanlin.Business" AutoEventWireup="true" %>

<%@Register tagPrefix="ctrl" tagName="Editor" src="~/themes/default/skins/Skin-HtmlEditor.ascx" %>

<script language="javascript" type="text/javascript">
<!--
    function GetCities(){
        var parentCategoryID = document.getElementById('<%= provinceDropDownList.ClientID %>').value;
        if(parentCategoryID != null)
        {             
	        AjaxManager.GetChildCategories('<%= ClientID %>', parentCategoryID,  GetCitiesCallBack);
        }
    }
    function GetTowns(){
        var parentCategoryID = document.getElementById('<%= cityDropDownList.ClientID %>').value;
        if(parentCategoryID != null)
        {             
	        AjaxManager.GetChildCategories('<%=ClientID %>', parentCategoryID,  GetTownsCallBack);
        }
    }
    function GetSmallTowns(){
        var parentCategoryID = document.getElementById('<%= townDropDownList.ClientID %>').value;
        if(parentCategoryID != null)
        {             
	        AjaxManager.GetChildCategories('<%=ClientID %>', parentCategoryID,  GetSmallTownsCallBack);
        }
    }
    function GetCitiesCallBack(res){
        var ddl = document.getElementById('<%= cityDropDownList.ClientID %>');
        ClearOptions(ddl);
     
        if(res.value == null || res.value == "")
        {
            return;
        }   
        var categories = res.value.split(";");
        for(var i = 0; i < categories.length; i++) { 
            var category = categories[i].split(":");
            var newOption=new Option(category[1],category[0]);
            ddl.options.add(newOption); 
        }  

        if(ddl.length > 0)
        {
            ddl.selectedIndex = 0;
            GetTowns(); 
        }
        
    }
    function GetTownsCallBack(res){
        var ddl = document.getElementById('<%= townDropDownList.ClientID %>');
        ClearOptions(ddl);
     
        if(res.value == null || res.value == "")
        {
            return;
        }   
        var categories = res.value.split(";");
        for(var i = 0; i < categories.length; i++) { 
            var category = categories[i].split(":");
            var newOption=new Option(category[1],category[0]);
            ddl.options.add(newOption); 
        }  

        if(ddl.length > 0)
        {
            ddl.selectedIndex = 0; 
            GetSmallTowns();
        }
    }
    function GetSmallTownsCallBack(res){
        var ddl = document.getElementById('<%= smallTownDropDownList.ClientID %>');
        ClearOptions(ddl);
     
        if(res.value == null || res.value == "")
        {
            return;
        }   
        var categories = res.value.split(";");
        for(var i = 0; i < categories.length; i++) { 
            var category = categories[i].split(":");
            var newOption=new Option(category[1],category[0]);
            ddl.options.add(newOption); 
        }  

        if(ddl.length > 0)
        {
            ddl.selectedIndex = 0; 
        }
    }
    function ClearOptions(list) { 
        while (list.options.length > 0) 
        { 
            list.options[0] = null; 
        } 
    }
    function checkvalue(){
        var companyNameValuedTextBox = document.getElementById('<%= companyNameValuedTextBox.ClientID %>');
        var postcodeValuedTextBox = document.getElementById('<%= companyPostCodeValuedTextBox.ClientID %>');
        var faxValuedTextBox = document.getElementById('<%= companyFaxNumberValuedTextBox.ClientID %>');
        var emailValuedTextBox = document.getElementById('<%= companyEmailValuedTextBox.ClientID %>'); 
        var qQCodeValuedTextBox = document.getElementById('<%= companyQQValuedTextBox.ClientID %>');
        var msnCodeValuedTextBox = document.getElementById('<%= companyMSNValuedTextBox.ClientID %>');
        var companyTypesCheckBoxList =  document.getElementById('<%= companyTypesCheckBoxList.ClientID %>');
        var provinceDropDownList =  document.getElementById('<%= provinceDropDownList.ClientID %>');
        var cityDropDownList =  document.getElementById('<%= cityDropDownList.ClientID %>');
        var townDropDownList =  document.getElementById('<%= townDropDownList.ClientID %>');
        var smallTownDropDownList =  document.getElementById('<%= smallTownDropDownList.ClientID %>');
        var companyContactPhone = document.getElementById('<%= companyContactPhoneValuedTextBox.ClientID %>');
        var companyTelephone1 = document.getElementById('<%= companyTelephone1ValuedTextBox.ClientID %>');
        var companyTelephone2 = document.getElementById('<%= companyTelephone2ValuedTextBox.ClientID %>');
        var companyScale = document.getElementById('<%= companyScaleValuedTextBox.ClientID %>');
        var companySite = document.getElementById('<%= companySiteValuedTextBox.ClientID %>');
        var greenNumberValuedTextBox = document.getElementById('<%= greenNumberValuedTextBox.ClientID %>');
        
        if(greenNumberValuedTextBox.value.Trim().length==0)
        {
            alert('绿商号不能为空！');
            greenNumberValuedTextBox.focus();
            return false; 
        }  
        if(companyNameValuedTextBox.value.Trim().length==0)
        {
            alert('企业名称不能为空！');
            companyNameValuedTextBox.focus();
            return false; 
        }  
        else if(companyNameValuedTextBox.value.Trim().length > 12)
        {
            alert('公司名称应为12个字以内！');
            companyNameValuedTextBox.focus();
            return false;
        }
        if(postcodeValuedTextBox.value != null && postcodeValuedTextBox.value.Trim().length > 0 && !isPostcode(postcodeValuedTextBox.value))
        {
            alert('请填写正确格式的邮政编码！');
            postcodeValuedTextBox.focus();
            return false;
        }
        if(emailValuedTextBox.value != null && emailValuedTextBox.value.Trim().length > 0 && !isEmail(emailValuedTextBox.value))
        {
            alert('请正确填写企业邮箱！');
            emailValuedTextBox.focus();
            return false; 
        }  
        if(companySite.value != null && companySite.value.Trim().length > 0 && !isURL(companySite.value))
        {
            alert('请正确填写企业主页,如www.xxx.com！');
            companySite.focus();
            return false; 
        }
        if(qQCodeValuedTextBox.value != null && qQCodeValuedTextBox.value.Trim().length > 0 && !isQQ(qQCodeValuedTextBox.value))
        {
            alert('请正确填写QQ号码！');
            qQCodeValuedTextBox.focus();
            return false; 
        }  
        if (msnCodeValuedTextBox.value != null && msnCodeValuedTextBox.value.Trim().length > 0 && (!isEmail(msnCodeValuedTextBox.value)))
        {
            alert('请填写正确格式的Msn！');
            msnCodeValuedTextBox.focus();
            return false;      
        }
        
        var chked=false;  
        var checks = companyTypesCheckBoxList.getElementsByTagName("input"); 
        var ichecked = 0;
        for(var n=0;n <checks.length;n++) 
        { 
            if(checks[n].type== "checkbox" && checks[n].checked==true) 
            { 
               chked=true; 
               ichecked=ichecked+1;
            } 
        } 
        if(!chked)
        {
            alert('请选择企业类型！');
            return false;
        } 
        
        if(provinceDropDownList.selectedIndex == "-1")
        {
            alert('请选择所在地区！');
            provinceDropDownList.focus();
            return false;
        } 
        if(cityDropDownList.selectedIndex == "-1")
        {
            alert('请选择所在地区！');
            cityDropDownList.focus();
            return false;
        } 
        if(townDropDownList.selectedIndex == "-1")
        {
            alert('请选择所在地区！');
            townDropDownList.focus();
            return false;
        } 
        if(smallTownDropDownList.selectedIndex == "-1")
        {
            alert('请选择所在地区！');
            provinceDropDownList.focus();
            return false;
        } 
        
        if(trim(companyContactPhone.value) != "" && !isMobile(trim(companyContactPhone.value)))
        {
            alert('请正确手机！');
            companyContactPhone.focus();
            return false;
        }

        if (trim(companyTelephone1.value) != "" || trim(companyTelephone2.value) != "")
        {
            if(!isTelephone(companyTelephone1.value+"-"+companyTelephone2.value))
            {
                alert('请正确填写固定电话！');
                companyTelephone1.focus();
                return false;
            }
        }
        
        if(trim(companyScale.value).length>28)
        {
            alert('经营范围最多填写28个字！');
            companyScale.focus();
            return false;
        }
        
        return true;
    }
//-->
</script>
<div class="AdminArea">
    <fieldset>
        <legend><nwap:ResourceLiteral runat="server" ResourceName="System_Applications_Yuanlin_AddCompanyCard" ResourceFile="ControlPanelResources.xml"></nwap:ResourceLiteral></legend>
		
		 <div class="FormRow">
            <div class="LargerFieldNameRequireCharacter">
                <nwap:ResourceLabel runat="Server" CssClass="RedColor" ResourceFile="ControlPanelResources.xml" ResourceName="RequireCharacter" />
                <nwap:ResourceLabel runat="Server" ControlToLabel="greenNumberValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_GreenNumber" />
            </div>
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="greenNumberValuedTextBox" />
        </div>
        <div class="FormRow">
            <div class="LargerFieldNameRequireCharacter">
                <nwap:ResourceLabel runat="Server" CssClass="RedColor" ResourceFile="ControlPanelResources.xml" ResourceName="RequireCharacter" />
                <nwap:ResourceLabel runat="Server" ControlToLabel="companyNameValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_CompanyName" />
            </div>
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyNameValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="companyAddressValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_CompanyAddress" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyAddressValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="LargerFieldName" runat="Server" ControlToLabel="companyContactPhoneValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="EditProfile_MobilePhone" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField SmallWidth" id="companyContactPhoneValuedTextBox" />&nbsp;&nbsp;&nbsp;&nbsp;
            <nwap:ResourceLabel runat="Server" ControlToLabel="companyTelephone1ValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="EditProfile_Phone" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField SmallWidth" id="companyTelephone1ValuedTextBox" Width="5%"/>
            <nwap:ResourceLabel runat="Server" ResourceFile="ControlPanelResources.xml" ResourceName="Register_Telephone_Seperator" />
            <nwap:ValuedTextBox runat="server" CssClass="InputField SmallWidth" ID="companyTelephone2ValuedTextBox" Width="15%"/>
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="companyPostCodeValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_Postcode" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyPostCodeValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="companyFaxNumberValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_Fax" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyFaxNumberValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="companyEmailValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_Email" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyEmailValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="companySiteValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_Homepage" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companySiteValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="companyQQValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_QQCode" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyQQValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="companyMSNValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_MsnCode" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyMSNValuedTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="LargerFieldName" runat="Server" ControlToLabel="companyScaleValuedTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="EditProfile_CompanyScale" />
            <nwap:ValuedTextBox Runat="server" CssClass="InputField LargerWidth" id="companyScaleValuedTextBox" />
        </div>
        <div class="FormRow">
            <div class="LargerFieldNameRequireCharacter">
                <nwap:ResourceLabel runat="Server" CssClass="RedColor" ResourceFile="ControlPanelResources.xml" ResourceName="RequireCharacter" />
                <nwap:ResourceLabel runat="Server" ControlToLabel="companyTypesCheckBoxList" ResourceFile="ControlPanelResources.xml" ResourceName="EditProfile_CompanyType" />
            </div>
            <asp:CheckBoxList Runat="server" CssClass="CategoryCheckboxList" RepeatDirection="Horizontal" RepeatColumns="5" id="companyTypesCheckBoxList" />
        </div>        
        <div class="FormRow">
            <div class="LargerFieldNameRequireCharacter">
                <nwap:ResourceLabel runat="Server" CssClass="RedColor" ResourceFile="ControlPanelResources.xml" ResourceName="RequireCharacter" />
                <nwap:ResourceLabel runat="Server" ControlToLabel="provinceDropDownList" ResourceFile="ControlPanelResources.xml" ResourceName="EditProfile_UserArea" />
            </div>
            <nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" onchange="GetCities()" id="provinceDropDownList" />
            &nbsp;&nbsp;<nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" onchange="GetTowns()" id="cityDropDownList" />
            &nbsp;&nbsp;<nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" onchange="GetSmallTowns()" id="townDropDownList" />
            &nbsp;&nbsp;<nwap:ValuedDropDownList Runat="server" CssClass="InputField MicroWidth" id="smallTownDropDownList" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="bodyValuedEditor" ResourceFile="ControlPanelResources.xml" ResourceName="System_Applications_Yuanlin_CompanyCard_Body" />
            <br /><br /><ctrl:Editor Runat="server" Width="100%" Height="250px" id="descriptionValuedEditor" />
        </div>
        <div class="FormRow SubmitButtonRow">
            <nwap:Resourcebutton id="SaveButton" ResourceName="Save" OnClientClick="return checkvalue()" CssClass="Button" Runat="server"></nwap:Resourcebutton>&nbsp;&nbsp;&nbsp;&nbsp;
            <nwap:Resourcebutton id="BackButton" ResourceName="Back" CssClass="Button" Runat="server"></nwap:Resourcebutton>
        </div>	
    </fieldset>
</div> 